package com.easyadmin.pro.common.controller;

import com.easyadmin.pro.common.enums.HttpCodeEnum;
import com.easyadmin.pro.common.vo.RestResult;

/**
 * packageName com.easyadmin.pro.common.controller
 *
 * @author 骑着蚂蚁去上天
 * @version JDK 17
 * @className ResultController
 * @date 2024/4/10
 * @description 数据返回基础
 */
public class ResultController {

    /**
     * 无数据返回
     * @return
     */
    public RestResult success() {
        return RestResult.success();
    }

    /**
     * 返回数据及信息
     * @param msg
     * @param data
     * @return
     */
    public RestResult success(String msg, Object data) {
        return RestResult.success(msg, data);
    }

    /**
     * 返回状态及信息
     * @param code
     * @param msg
     * @return
     */
    public RestResult success(Integer code, String msg) {
        return RestResult.success(code, msg);
    }

    /**
     * 返回数据
     * @param data
     * @return
     */
    public RestResult success(Object data) {
        return RestResult.success(data);
    }

    /**
     * 返回状态、信息、数据
     * @param code
     * @param msg
     * @param data
     * @return
     */
    public RestResult success(Integer code, String msg, Object data) {
        return RestResult.success(code, msg, data);
    }

    /**
     * 异常返回状态及信息
     * @param code
     * @param msg
     * @return
     */
    public RestResult error(Integer code, String msg) {
        return RestResult.lose(code, msg);
    }

    /**
     * 异常返回枚举
     * @param httpCodeEnum
     * @return
     */
    public RestResult error(HttpCodeEnum httpCodeEnum) {
        return RestResult.lose(httpCodeEnum);
    }

    /**
     * 返回异常信息
     * @param msg
     * @return
     */
    public RestResult error(String msg) {
        return RestResult.lose(msg);
    }
}